package sketch.seg.cd;

import java.util.ArrayList;
import java.util.List;

import sketch.ink.SampledPoint;
import sketch.ink.Stroke;

public class CornerDetector {



	public CDFactory.TYPE getType() {
		String name = this.getClass().getSimpleName();
		return CDFactory.TYPE.valueOf(name.replaceAll("CD", ""));
	}

	private List<SampledPoint> points;

	private Stroke host;

	public CornerDetector(Stroke s) {
		host = s;
	}

	public CornerDetector() {}

	public Stroke getHost() {
		return host;
	}

	public void setHost(Stroke s) {
		clear();
		host = s;
	}

	public List<SampledPoint> getPoints() {
		return points;
	}

	private List<SampledPoint> corners = null;

	public void clear() {
		corners = null;
	}

	public List<SampledPoint> getCorners() {
		if (corners == null)
			detectCorners();

		return corners;
	}

	public void setCorners(List<SampledPoint> cs) {
		corners = cs;
	}

	protected void detectCorners() {
		corners = new ArrayList<SampledPoint>();
		if (getHost() != null)
			setPoints(getHost().getPoints());
	}

	public void setPoints(List<SampledPoint> ps) {
		points = ps;
		clear();
//		detectCorners();
	}





}
